var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
var UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin');

module.exports = {
	entry: {
		app: './src/js/app.js',
		vendor: ['react', 'react-dom', 'react-redux', 'redux']
	},
	output: {
		path: path.join(__dirname, 'dist'),
		filename: 'js/[name].js'
	},
	module: {
		loaders: [{
			test: /\.js?$/,
			loader: 'babel',
			query: {
				presets: ['es2015', 'react']
			},
			exclude: /node_modules/
		}, {
			test: /\.css$/,
			loader: ExtractTextPlugin.extract("style-loader", "css-loader")
		}, {
			test: /\.(png|eof|woff|ttf|svg|eot|woff2)$/,
			loader: "url-loader?limit=100000"
		}, {
			test: /\.jpg$/,
			loader: "file-loader"
		}]
	},
	plugins: [
		new CommonsChunkPlugin(['vendor'], 'common.js'),
		new HtmlWebpackPlugin({
			template: './src/index.ejs'
		}),
		new ExtractTextPlugin("styles.css"),
		/*new UglifyJsPlugin({
			compress: {
				warnings: false
			}
		})*/
	]
}